package com.xf.service.impl;

import com.xf.service.HelloService;
import org.apache.dubbo.config.annotation.Service;

/**
 * @ClassName HelloServiceImpl
 * @Deseription TODO
 * @Author fx
 * @Date 2021/4/27 0027 21:29
 * @Version 1.0
 **/
@Service
public class HelloServiceImpl implements HelloService {

    /**
     * @Author fx
     * @Description 随机等待1-100ms
     * @ClassName HelloServiceImpl
     * @Date 21:48 2021/4/27 0027
     * @Param
     * @return
     **/
    private void sleep(){
        /** 获取随机 1-100 之间数字*/
        int num = (int)(Math.random() * 100);
        try{
            Thread.sleep(num);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public String sayHelloA(String name){
        System.out.println("this is A method!");
        sleep();
        return "sayHelloA :"+name;
    }

    public String sayHelloB(String name) {
        System.out.println("this is B method");
        sleep();
        return "sayHelloB :"+name;
    }

    public String sayHelloC(String name) {
        System.out.println("this is C method");
        sleep();
        return "sayHelloC :"+name;
    }
}
